fix: MiMo ASR API Key 为空竞态修复#632
Merged
Merged
Conversation
1. CredentialField onBlur: save() fire-and-forget 与 validate 按钮存在 IPC 竞态 — 用户输入 Key 后立即点「测试连接」时 setCredential 可能晚于 validate 到达后端。 — 添加 mountedRef 守卫防止组件卸载后 stale save。 2. read_mimo_credentials: 将 .ok().flatten().unwrap_or_default() 改为显式 match — keyring 读取失败不再静默吞错,分别用 warn/error 记日志。
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
问题
小米 MiMo ASR 在填写完所有信息后,「测试连接」或开始听写时提示 API Key 为空。
根因
三个环节的竞态条件叠加:
1. 前端 onBlur 与 validate 按钮的 IPC 竞态
`CredentialField.onBlur` 触发 `save()`(async)但未 `await`。用户输入 Key 失焦后立即点「测试连接」时,`validateProviderCredentials` 的 IPC 可能在 `setCredential` IPC 完成前到达后端,读到空的凭据缓存。
2. 组件卸载后 stale save 未取消
`CredentialField` 通过 `key` prop 在 provider 切换时强制 remount,但飞行中的 debounce save 没有挂载守卫。旧组件的 `setCredential` IPC 可能在 `active.asr` 已切换后才到达后端,把空值写入新 provider。
3. 后端 read_mimo_credentials 静默吞错
`CredentialsVault::get().ok().flatten().unwrap_or_default()` 链将 keyring 读取错误静默转成空串,外部完全感知不到。
修复
验证
PR Type
Bug fix
Description
Add mountedRef guards to prevent stale saves after unmount
Change onBlur to void save() to avoid race with validate IPC
Improve error logging in read_mimo_credentials instead of silent defaults
Diagram Walkthrough
File Walkthrough
llm_pipeline.rs
Improve error handling in read_mimo_credentialsopenless-all/app/src-tauri/src/coordinator/llm_pipeline.rs
match for credential retrieval
fails
ProvidersSection.tsx
Add mount guard and fix onBlur race conditionopenless-all/app/src/pages/settings/ProvidersSection.tsx
unmount
race with validate